package com.ag.zrt.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbTaskStatus;
import com.ag.common.AgException;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;
import com.ag.zrt.dao.TbTaskStatusDAO;
import com.ag.zrt.service.TaskStatusService;
@Service("TaskStatusService")
public class TaskStatusServiceImpl implements TaskStatusService {
	
	@Resource(name="ZRTTbTaskStatusDAO")
	private TbTaskStatusDAO taskStatusDAO;
	@Resource(name="iDServiceImpl")
	private IIDService idService;

	public void setTaskStatusDAO(TbTaskStatusDAO taskStatusDAO) {
		this.taskStatusDAO = taskStatusDAO;
	}

	public void update(TbTaskStatus ts) {
		// TODO Auto-generated method stub
		ts.setA(IDUtil.PRESERVE);
		taskStatusDAO.attachDirty(ts);
	}

	public void delete(TbTaskStatus ts) {
		// TODO Auto-generated method stub
		TbTaskStatus tts = taskStatusDAO.findById(ts.getTsId());
		tts.setA(IDUtil.DELETE);
		taskStatusDAO.attachDirty(tts);

	}

	public List<TbTaskStatus> findAll() {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		sb.append("from TbTaskStatus ts where ts.a ="+IDUtil.PRESERVE);
		return taskStatusDAO.find(sb.toString());
	}

	public void save(TbTaskStatus ts) throws Exception {
		// TODO Auto-generated method stub
		String tsId = idService.findTablePK(
				IDUtil.TB_TASK_STATUS);
		ts.setTsId(tsId);
		ts.setA(IDUtil.PRESERVE);
		taskStatusDAO.save(ts);

	}

	public TbTaskStatus findById(String id) {
		// TODO Auto-generated method stub
		return taskStatusDAO.findById(id);
	}

}
